package com.yubest.springmvcjsp.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @Author hweiyu
 * @Description
 * @Date 2022/9/21 16:43
 */
@Controller
public class LoginController {

    @GetMapping(value = "/toLogin")
    public String login() {
        return "login";
    }

    @PostMapping(value = "/login")
    public String login(@RequestParam String username, @RequestParam String password, Model model) {
        if ("admin".equals(username) && "123456".equals(password)) {
            model.addAttribute("status", true);
            model.addAttribute("msg", username + "，你好，恭喜登陆成功！");
        } else {
            model.addAttribute("status", false);
            model.addAttribute("msg", username + "，你好，登陆失败！");
        }
        return "hello";
    }
}
